NcApi
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
NcApi.h File Reference
#include <stdint.h>
Include dependency graph for NcApi.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  NcApiHostAck
 HostAck or HostNAck package received. More...
 
struct  NcApiHostData
 HostData package received. More...
 
struct  NcApiHostDataHapa
 HostDataHapa package received. More...
 
struct  NcApiWesRequest
 WesRequest package received. More...
 
struct  NcApiWesResponse
 WesResponse package received. More...
 
struct  NcApiWesCmdMsg
 
struct  NcApiWesStatus
 WesStatus package received. More...
 
struct  NcApiRxHandlers
 Set of application callbacks to handle any received messages. Each callback is optional allowing the application to register specific callbacks only for the message types of particular interest. More...
 
struct  NcApiSendParams
 Parameters for the NcApiSendAcknowledged function. More...
 
struct  NcApiWesCmdParams
 Parameters for the NcApiWesCmd function. More...
 
struct  NcApiWesResponseParams
 Parameters for the NcApiWesCmd function. More...
 
struct  NcApi
 RX and TX buffers for a particular UART. Managed by NcApi and as such the fields are considered internal to NcApi. More...
 

Macros

#define NCAPI_TXBUFFER_SIZE   32
 Default TX buffer size. Can be defined by the application. More...
 
#define NCAPI_MAX_PAYLOAD_LENGTH   (NCAPI_TXBUFFER_SIZE-5)
 
#define NCAPI_RXBUFFER_SIZE   255
 Default RX buffer size. Can be defined by the application. More...
 

Typedefs

typedef struct NcApiHostAck tNcApiHostAck
 HostAck or HostNAck package received. More...
 
typedef struct NcApiHostData tNcApiHostData
 HostData package received. More...
 
typedef struct NcApiHostDataHapa tNcApiHostDataHapa
 HostDataHapa package received. More...
 
typedef struct NcApiWesRequest tNcApiWesRequest
 WesRequest package received. More...
 
typedef struct NcApiWesResponse tNcApiWesResponse
 WesResponse package received. More...
 
typedef struct NcApiWesCmdMsg tNcApiWesCmd
 
typedef struct NcApiWesStatus tNcApiWesStatus
 WesStatus package received. More...
 
typedef void(* pfnNcApiReadCallback) (uint8_t n, uint8_t *msg, uint8_t msgLength)
 Application provided function that NcApi calls whenever any valid NeocCortec messages has been received. More...
 
typedef void(* pfnNcApiHostAckCallback) (uint8_t n, tNcApiHostAck *m)
 Application provided function that NcApi calls when a HostAck or HostNAck message has been received. More...
 
typedef void(* pfnNcApiHostDataCallback) (uint8_t n, tNcApiHostData *m)
 Application provided function that NcApi calls when a HostData message has been received. More...
 
typedef void(* pfnNcApiHostDataHapaCallback) (uint8_t n, tNcApiHostDataHapa *m)
 Application provided function that NcApi calls when a HostDataHapa message has been received. More...
 
typedef void(* pfnNcApiWesRequestCallback) (uint8_t n, tNcApiWesRequest *m)
 Application provided function that NcApi calls when a WesRequest message has been received. More...
 
typedef void(* pfnNcApiWesStatusCallback) (uint8_t n, tNcApiWesStatus *m)
 Application provided function that NcApi calls when a WesStatus message has been received. More...
 
typedef struct NcApiRxHandlers tNcApiRxHandlers
 Set of application callbacks to handle any received messages. Each callback is optional allowing the application to register specific callbacks only for the message types of particular interest. More...
 
typedef struct NcApiSendParams tNcApiSendParams
 Parameters for the NcApiSendAcknowledged function. More...
 
typedef struct NcApiWesCmdParams tNcApiWesCmdParams
 Parameters for the NcApiWesCmd function. More...
 
typedef struct NcApiWesResponseParams tNcApiWesResponseParams
 Parameters for the NcApiWesCmd function. More...
 
typedef struct NcApi tNcApi
 RX and TX buffers for a particular UART. Managed by NcApi and as such the fields are considered internal to NcApi. More...
 

Enumerations

enum  NcApiWesCmdValues { NCAPI_WES_STOP = 0, NCAPI_WES_STARTSERVER = 1, NCAPI_WES_REQUESTSTATUS = 2, NCAPI_WES_STARTCLIENT = 3 }
 
enum  NcApiWesStatusValues { NCAPI_WES_STOPPED = 0, NCAPI_WES_SERVERRUNNING = 1, NCAPI_WES_CLIENTRUNNING = 2 }
 
enum  NcApiErrorCodes {
  NCAPI_OK = 0, NCAPI_ERR_NODEID = 1, NCAPI_ERR_DESTPORT = 2, NCAPI_ERR_PAYLOAD = 3,
  NCAPI_ERR_ENQUEUED = 4, NCAPI_ERR_NULLPAYLOAD = 5, NCAPI_ERR_NOARGS = 6
}
 

Functions

void NcApiCallbackCtsActive (uint8_t n)
 Callback from the application into NcApi whenever CTS becomes active. More...
 
void NcApiTxData (uint8_t n, uint8_t *finalMsg, uint8_t finalMsgLength)
 Application provied function that NcApi calls if there is any pending data to be written to the UART. More...
 
void NcApiMessageWrittenCallback (uint8_t n, void *callbackToken, uint8_t *finalMsg, uint8_t finalMsgLength)
 Application provided function that NcApi calls after it has succesfully written the message. More...
 
void NcApiRxDataReceived (uint8_t n, uint8_t byte)
 Callback from the application into NcApi whenever a byte is received on the UART. More...
 
void NcApiInit ()
 Initializes the allocated instances of tNcApi. More...
 
NcApiErrorCodes NcApiSendAcknowledged (uint8_t n, tNcApiSendParams *args)
 Sends one CommandAckowledged message. More...
 
NcApiErrorCodes NcApiSendWesCmd (uint8_t n, tNcApiWesCmdParams *args)
 Sends one WesCmd message. More...
 
NcApiErrorCodes NcApiSendWesResponse (uint8_t n, tNcApiWesResponseParams *args)
 Sends one WesResponse message. More...
 
void NcApiCancelEnqueuedMessage (uint8_t n)
 Cancels any enqueued message. More...
 

Variables

tNcApiRxHandlers g_ncRx
 Application defined and configured rx-handlers. More...
 
tNcApi g_ncApi []
 Application defined array of NcApi instances in use. More...
 
uint8_t g_numberOfNcApis
 Application defined number of elements in the g_ncApi array. More...
 

Macro Definition Documentation

#define NCAPI_MAX_PAYLOAD_LENGTH   (NCAPI_TXBUFFER_SIZE-5)
#define NCAPI_RXBUFFER_SIZE   255

Default RX buffer size. Can be defined by the application.

#define NCAPI_TXBUFFER_SIZE   32

Default TX buffer size. Can be defined by the application.

Typedef Documentation

typedef void(* pfnNcApiHostAckCallback) (uint8_t n, tNcApiHostAck *m)

Application provided function that NcApi calls when a HostAck or HostNAck message has been received.

Parameters
nIndex of tNcApi instance that the message was received from
mStrongly typed message
typedef void(* pfnNcApiHostDataCallback) (uint8_t n, tNcApiHostData *m)

Application provided function that NcApi calls when a HostData message has been received.

Parameters
nIndex of tNcApi instance that the message was received from
mStrongly typed message
typedef void(* pfnNcApiHostDataHapaCallback) (uint8_t n, tNcApiHostDataHapa *m)

Application provided function that NcApi calls when a HostDataHapa message has been received.

Parameters
nIndex of tNcApi instance that the message was received from
mStrongly typed message
typedef void(* pfnNcApiReadCallback) (uint8_t n, uint8_t *msg, uint8_t msgLength)

Application provided function that NcApi calls whenever any valid NeocCortec messages has been received.

Parameters
nIndex of tNcApi instance that the message was received from
msgPointer to the message
msgLengthMessage length in bytes
typedef void(* pfnNcApiWesRequestCallback) (uint8_t n, tNcApiWesRequest *m)

Application provided function that NcApi calls when a WesRequest message has been received.

Parameters
nIndex of tNcApi instance that the message was received from
mStrongly typed message
typedef void(* pfnNcApiWesStatusCallback) (uint8_t n, tNcApiWesStatus *m)

Application provided function that NcApi calls when a WesStatus message has been received.

Parameters
nIndex of tNcApi instance that the message was received from
mStrongly typed message
typedef struct NcApi tNcApi

RX and TX buffers for a particular UART. Managed by NcApi and as such the fields are considered internal to NcApi.

typedef struct NcApiHostAck tNcApiHostAck

HostAck or HostNAck package received.

typedef struct NcApiHostData tNcApiHostData

HostData package received.

HostDataHapa package received.

Set of application callbacks to handle any received messages. Each callback is optional allowing the application to register specific callbacks only for the message types of particular interest.

Parameters for the NcApiSendAcknowledged function.

typedef struct NcApiWesCmdMsg tNcApiWesCmd

Parameters for the NcApiWesCmd function.

WesRequest package received.

WesResponse package received.

Parameters for the NcApiWesCmd function.

WesStatus package received.

Enumeration Type Documentation

Enumerator
NCAPI_OK 

Success.

NCAPI_ERR_NODEID 

NodeId cannot be 0.

NCAPI_ERR_DESTPORT 

Port must be [0..3].

NCAPI_ERR_PAYLOAD 

No payload supplied.

NCAPI_ERR_ENQUEUED 

There is already one pending message waiting to be written to the UART.

NCAPI_ERR_NULLPAYLOAD 

Payload length supplied but no payload.

NCAPI_ERR_NOARGS 

No arguments pointer.

Enumerator
NCAPI_WES_STOP 

Stop.

NCAPI_WES_STARTSERVER 

Start server.

NCAPI_WES_REQUESTSTATUS 

Request status.

NCAPI_WES_STARTCLIENT 

Start client.

Enumerator
NCAPI_WES_STOPPED 

Stopped.

NCAPI_WES_SERVERRUNNING 

Server is running.

NCAPI_WES_CLIENTRUNNING 

Client is running.

Function Documentation

void NcApiCallbackCtsActive ( uint8_t  n)

Callback from the application into NcApi whenever CTS becomes active.

Parameters
nIndex of tNcApi instance that the CTS interrupt relates to
void NcApiCancelEnqueuedMessage ( uint8_t  n)

Cancels any enqueued message.

Parameters
nIndex of tNcApi instance where the message should be dequeued
void NcApiInit ( )

Initializes the allocated instances of tNcApi.

void NcApiMessageWrittenCallback ( uint8_t  n,
void *  callbackToken,
uint8_t *  finalMsg,
uint8_t  finalMsgLength 
)

Application provided function that NcApi calls after it has succesfully written the message.

Parameters
nIndex of tNcApi instance that message was written to
callbackTokenApplication provided context / token / tag
finalMsgPointer to the message
finalMsgLengthMessage length in bytes
void NcApiRxDataReceived ( uint8_t  n,
uint8_t  byte 
)

Callback from the application into NcApi whenever a byte is received on the UART.

Parameters
nIndex of tNcApi instance that the byte relates to
byteThe byte received
NcApiErrorCodes NcApiSendAcknowledged ( uint8_t  n,
tNcApiSendParams args 
)

Sends one CommandAckowledged message.

Parameters
nIndex of tNcApi instance that the message should be sent via
argsPointer to instance of tNcApiSendParams that holds the parameters
Returns
0 upon success. Anything else is an error
NcApiErrorCodes NcApiSendWesCmd ( uint8_t  n,
tNcApiWesCmdParams args 
)

Sends one WesCmd message.

Parameters
nIndex of tNcApi instance that the message should be sent via
argsPointer to instance of tNcApiWesCmdParams that holds the parameters
Returns
0 upon success. Anything else is an error
NcApiErrorCodes NcApiSendWesResponse ( uint8_t  n,
tNcApiWesResponseParams args 
)

Sends one WesResponse message.

Parameters
nIndex of tNcApi instance that the message should be sent via
argsPointer to instance of tNcApiWesResponse that holds the parameters
Returns
0 upon success. Anything else is an error
void NcApiTxData ( uint8_t  n,
uint8_t *  finalMsg,
uint8_t  finalMsgLength 
)

Application provied function that NcApi calls if there is any pending data to be written to the UART.

Parameters
nIndex of tNcApi instance that the data should be written to, ie. which UART
finalMsgPointer to the buffer
finalMsgLengthNumber of bytes to be written

Variable Documentation

tNcApi g_ncApi[]

Application defined array of NcApi instances in use.

Application defined and configured rx-handlers.

uint8_t g_numberOfNcApis

Application defined number of elements in the g_ncApi array.